<template>
  <view class="view">
    <web-view :webview-styles="webviewStyles" :src="viewPath"></web-view>
  </view>
</template>

<script>
import config from "@/Config";

export default {
  name: "file-view",
  data() {
    return {
      viewPath: "",
      webviewStyles: {
        progress: {
          color: "#FF3333",
        },
      },
    };
  },
  onLoad: function (option) {
    if (typeof option != "object") return;
    if (!option.url) return;
    const url = `${config.fileBaseUrl}${option.url}`;
    let encodeUrl = encodeURIComponent(this.$base.encode(url));
    let viewPath = `${config.viewUrl}?url=${encodeUrl}&officePreviewType=pdf`;
    console.log(viewPath);
    this.viewPath = viewPath;
  },
};
</script>

<style lang="scss">
</style>